﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Se.Model.Data
{
    public static class DBEntityCommon
    {
        /// <summary>
        /// 转换Entity数组
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entitybaseSet"></param>
        /// <returns></returns>
        public static T[] ConvertEntityArray<T>( DataEntityBase[] entitybaseSet) where T : DataEntityBase
        {
            T[] entitySet = new T[entitybaseSet.Length];
            for (var i = 0; i < entitybaseSet.Length; i++)
            {
                entitySet[i] = (T)entitybaseSet[i];
            }
            return entitySet;
        }

        /// <summary>
        /// 转换Entity数组
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entities"></param>
        /// <returns></returns>
        public static DataEntityBase[] ConvertEntityBaseArray<T>(T[] entities) where T : DataEntityBase
        {
            DataEntityBase[] entitySet = new DataEntityBase[entities.Length];
            for (var i = 0; i < entities.Length; i++)
                entitySet[i] = entities[i];
            return entitySet;
        }
    }
}
